//////////////////////////////////////////////////////////////////////////////////
//	Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#include <wx/wx.h>
#include <wx/bookctrl.h>
#include <wx/slider.h>
#include <wx/spinctrl.h>
#include "wx/image.h"
#include "wx/artprov.h"
#include "wx/imaglist.h"
#include "propertydlg.h"
#include "propertystorage.h"
#include "levelchooser.h"
#include "reactionchooser.h"
#include "guilogic.h"
#include "generaloptions.h"
#include "syslogoptions.h"
#include "notifyoptions.h"
#include "rcmdapp.h"
#include "scheduleroptions.h"
#include "logoptions.h"
#include "portforwardoptions.h"

enum cSliderID
{
	cSliderIDBASE=10000,
};

BEGIN_EVENT_TABLE(CPropertyDlg, wxPropertySheetDialog)
	EVT_HELP(wxID_ANY, CPropertyDlg::OnHelp)
	EVT_BUTTON(wxID_HELP, CPropertyDlg::OnHelpButton)
END_EVENT_TABLE()


CPropertyDlg::CPropertyDlg( CPropertyStorage& propStorage ):m_propStorage(propStorage)
{
	SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
	
	const wxSize imageSize(24, 24);

	m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());

	wxImage icnTmp;

	int idx = 5;

	//General
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("general_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));


	//Nat
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("nat_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Mem
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("mem_options.ico"),   wxBITMAP_TYPE_ICO, 9 ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Route
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("route_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//CPU
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("cpu_options.ico"),   wxBITMAP_TYPE_ICO, 9 ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Sys Log
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("syslog_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Notify
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("notify_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Scheduler
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("sched_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Log
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("log_options.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	//Port Forward
	if ( icnTmp.LoadFile(wxGetApp().GetImageDir()+wxT("options_pfrwrd.ico"),   wxBITMAP_TYPE_ICO, idx ) )
	{
		m_imageList->Add( icnTmp );
	}
	else
		m_imageList->Add(wxArtProvider::GetIcon(wxART_NEW, wxART_OTHER, imageSize));

	m_imageList->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
	m_imageList->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
    m_imageList->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
	m_imageList->Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
	m_imageList->Add(wxArtProvider::GetIcon(wxART_CDROM, wxART_OTHER, imageSize));
}

CPropertyDlg::~CPropertyDlg(void)
{
	 delete m_imageList;
	 m_imageList=NULL;
}

bool CPropertyDlg::Create (PANELTYPE plCur, wxWindow *parent, wxWindowID id, const wxString &title,
						   const wxPoint &pos, const wxSize &size, long style, const wxString &name)
{
	bool bRes(true);

	try
	{
		//SetSheetStyle(wxPROPSHEET_LISTBOOK);
		//SetSheetStyle(wxPROPSHEET_TOOLBOOK);
		SetSheetStyle(wxPROPSHEET_TREEBOOK);

		if (!wxPropertySheetDialog::Create(parent, id, title, pos, size, style, name))
			return false;

		CreateButtons(wxOK|wxCANCEL|wxHELP);
		
		GetBookCtrl()->SetImageList(m_imageList);

		m_pGeneral = new CGeneralOptions( GetBookCtrl() );
		GetBookCtrl()->AddPage(m_pGeneral, _("General"), false, 0);

		LoadGeneralPageData();
		
		// Add page
		wxPanel* pNat = new wxPanel( GetBookCtrl(), wxID_ANY );
		FillPage(pNat, cPTNAT, true );
		GetBookCtrl()->AddPage(pNat, CGUILogic::PanelToName(cPTNAT), plCur==cPTNAT, 1);

		wxPanel* pMem = new wxPanel( GetBookCtrl(), wxID_ANY );
		FillPage(pMem, cPTMem );
		GetBookCtrl()->AddPage(pMem, CGUILogic::PanelToName(cPTMem), plCur==cPTMem, 2);

		wxPanel* pRoute = new wxPanel( GetBookCtrl(), wxID_ANY );
		FillPage(pRoute, cPTRoute );
		GetBookCtrl()->AddPage(pRoute, CGUILogic::PanelToName(cPTRoute), plCur==cPTRoute,3);

		wxPanel* pCPU = new wxPanel( GetBookCtrl(), wxID_ANY );
		FillPage(pCPU, cPTCPU );
		GetBookCtrl()->AddPage(pCPU, CGUILogic::PanelToName(cPTCPU), plCur==cPTCPU, 4);

		m_pSysLog = new CSysLogOptions( GetBookCtrl() );
		GetBookCtrl()->AddPage(m_pSysLog, _("SysLog"), false, 5);

		LoadSysLogPageData();

		m_pNotify = new CNotifyOptions( GetBookCtrl() );
		GetBookCtrl()->AddPage(m_pNotify, _("Notification"), false, 6);

		LoadNotifyPageData();


		m_pScheduler = new CSchedulerOptions( GetBookCtrl() );
		GetBookCtrl()->AddPage(m_pScheduler, _("Scheduler"), false, 7);

		LoadSchedulerPageData();

		m_pLogOptions = new CLogOptions( GetBookCtrl() );
		GetBookCtrl()->AddPage(m_pLogOptions, _("Log"), false, 8);

		LoadLogPageData();

		m_pPFOptions = new CPortForwardOptions( GetBookCtrl() );
		GetBookCtrl()->AddPage(m_pPFOptions, _("P. Forward"), false, 9);

		LoadPortForwardPageData();

		//SetInnerSize( &wxSize(800,600) );

		LayoutDialog();
	}
	catch(...)
	{
		wxLogError( _("Can't create general options dialog") );
	}

	//GetBookCtrl()->SetSelection(cPropPageMem);
	
	return bRes;
}

void CPropertyDlg::FillPage( class wxPanel* pPage, PANELTYPE type, bool bHaveDigradeProtection/*=false*/)
{
	try
	{
		PROPENTRY pp;
		m_propStorage.GetProperty( type, pp );
		
		wxFlexGridSizer* pSizer = new wxFlexGridSizer(2, 2, 5, 5);
		
		//Threshold selection
		wxStaticBoxSizer* pBox = new wxStaticBoxSizer( new
				wxStaticBox(pPage, wxID_ANY,  _("Threshold")), wxVERTICAL);

		CLevelChooser* pChooser=new CLevelChooser(pPage);
		
		pChooser->SetWarningLevel( pp.btWarningLevel );
		pChooser->SetAlarmLevel( pp.btAlarmLevel );
		
 		pBox->Add(pChooser, 1, wxALL|wxEXPAND|wxALIGN_CENTER, 5);
		pSizer->Add( pBox, 1, wxALL|wxEXPAND, 5 );
		
		wxStaticBoxSizer* pBox2 = new wxStaticBoxSizer( new
				wxStaticBox(pPage, wxID_ANY, _("Reaction")), wxVERTICAL);
		CReactionChooser* pReact = new CReactionChooser(pPage, type);
		
		//Fill react data
		pReact->SetWarningStrat( pp.onWarning );
		pReact->SetAlarmStrat( pp.onAlarm );
		pReact->SetWarningScript( pp.onWarningScript );
		pReact->SetAlarmScript( pp.onAlarmScript );

		pBox2->Add(pReact, 1, wxALL|wxEXPAND|wxALIGN_CENTER, 5);
		pSizer->Add( pBox2, 1, wxALL|wxEXPAND, 5 );
		pPage->SetSizer( pSizer );

		UIDATA data;

		data.pEnableLeaksProtection = NULL;

		if ( bHaveDigradeProtection )
		{
			data.pEnableLeaksProtection = new wxCheckBox(pPage,wxID_ANY, _("Reboot or repair if leaked more than 100% of table"));
			pSizer->Add(data.pEnableLeaksProtection, 1, wxALL|wxEXPAND, 5);
			data.pEnableLeaksProtection->SetValue(pp.bEnableRepair);
		}

		data.type = type;
		data.pLevel = pChooser;
		data.pReaction = pReact;
		
		m_uiData.push_back(data);
	}
	catch(...)
	{
		wxLogError( _("Can't load Page %d"),  type);
	}
}

void CPropertyDlg::LoadGeneralPageData()
{
	try
	{
		//Run at startup
		m_pGeneral->SetBootRun( m_propStorage.GetBootRun() );

		//Check for updates
		m_pGeneral->SetUpdCheck( m_propStorage.GetUpdCheck() );

		//Language
		m_pGeneral->SetLanguage( m_propStorage.GetLanguage() );

		//NAT Optimization
		m_pGeneral->SetEnableNATOpt( m_propStorage.GetEnableNATOpt() );

		//NAT Size Optimization
		m_pGeneral->SetEnableNATSizeOpt( m_propStorage.GetEnableNATSizeOpt() );

		//Peer To Peer
		m_pGeneral->SetEnableP2PNetworkOpt( m_propStorage.GetEnableP2PNetworkOpt() );

		//WWW
		m_pGeneral->SetEnableWWWOpt( m_propStorage.GetEnableWWWOpt() );

		//TCP
		m_pGeneral->SetEnableTCPOpt( m_propStorage.GetEnableTCPOpt() );

		//icmp
		m_pGeneral->SetEnableICMPOpt( m_propStorage.GetEnableICMPOpt() );

		//Advanced
		m_pGeneral->SetEnableAdvancedOpt( m_propStorage.GetEnableAdvancedOpt() );
		m_pGeneral->SetAdvancedOptList( m_propStorage.GetAdvancedOptList() );

		//StartUP Script
		m_pGeneral->SetEnableStartUpScript( m_propStorage.GetEnableStartUpScript() );
		m_pGeneral->SetStartUpScriptFileName( m_propStorage.GetStartUpScriptFileName() );

		//Proc Kill
		m_pGeneral->SetEnableProcKill( m_propStorage.GetEnableProcKill() );
		m_pGeneral->SetProcKillList( m_propStorage.GetProcKillList() );

		//Mod Unload
		m_pGeneral->SetEnableModUnload( m_propStorage.GetEnableModUnload() );
		m_pGeneral->SetModUnloadList( m_propStorage.GetModUnloadList() );


	}
	catch(...)
	{
		wxLogError( _("Can't load GeneralPageData") );
	}
}

void CPropertyDlg::LoadSysLogPageData()
{
	try
	{
		m_pSysLog->SetSysLogFromRouterOnly( m_propStorage.GetSysLogFromRouterOnly() );
		m_pSysLog->SetSysLogActions( m_propStorage.GetSysLogActions() );
		m_pSysLog->SetLogBlockedMAC( m_propStorage.GetLogBlockedMAC() );

		m_pSysLog->SetEnableSyslogSave( m_propStorage.GetEnableSyslogSave() );
		m_pSysLog->SetSyslogSaveFileName( m_propStorage.GetSyslogSaveFileName() );
		m_pSysLog->SetSyslogSaveLimit( m_propStorage.GetSyslogSaveLimit() );
		m_pSysLog->SetSysLogUDPPort( m_propStorage.GetSysLogUDPPort() );

		m_pSysLog->SetEnableSyslogAutoConfig( m_propStorage.GetEnableSyslogAutoConfig() );
		m_pSysLog->SetSyslogAutoConfigLevel( m_propStorage.GetSyslogAutoConfigLevel() );
	}
	catch(...)
	{
		wxLogError( _("Can't load SysLogPageData") );
	}
}

void CPropertyDlg::LoadNotifyPageData()
{
	try
	{
		//SMTP Server
		m_pNotify->SetSMTPServer( m_propStorage.GetSMTPServer() );

		//SMTP Server Port
		m_pNotify->SetSMTPServerPort( m_propStorage.GetSMTPServerPort() );

		//SMTP User
		m_pNotify->SetSMTPUser(m_propStorage.GetSMTPUser());

		//SMTP Passw
		m_pNotify->SetSMTPPassw(m_propStorage.GetSMTPPassw());

		//SMTP From
		m_pNotify->SetSMTPFrom( m_propStorage.GetSMTPFrom());

		//SMTP From
		m_pNotify->SetSMTPTo( m_propStorage.GetSMTPTo());

		//Send application Log
		m_pNotify->SetSendAppLog(m_propStorage.GetSendAppLog());

		//Send syslog Log
		m_pNotify->SetSendSysLog(m_propStorage.GetSendSysLog());

		//Send syslog Log Level
		m_pNotify->SetSyslogSendLevel( m_propStorage.GetSyslogSendLevel() );

		//Send interval
		m_pNotify->SetSendPeriod(m_propStorage.GetSendPeriod());
	}
	catch(...)
	{
        wxLogError( _("Can't load NotifyPageData") );
	}
}

void CPropertyDlg::LoadSchedulerPageData()
{
	m_pScheduler->SetSchedulerEnabled( m_propStorage.GetSchedulerEnabled() );
	m_pScheduler->SetScheduler( m_propStorage.GetScheduler() );
}

void CPropertyDlg::LoadLogPageData()
{
	m_pLogOptions->SetEnableAppLogSave( m_propStorage.GetEnableAppLogSave() );
	m_pLogOptions->SetAppLogSaveFileName( m_propStorage.GetAppLogSaveFileName() );
	m_pLogOptions->SetAppLogSaveLimit( m_propStorage.GetAppLogSaveLimit() );
	m_pLogOptions->SetAppLogStatusInterval( m_propStorage.GetAppLogStatusInterval() );
	m_pLogOptions->SetEnablePerfomanceLog( m_propStorage.GetEnablePerfomanceLog() );
	m_pLogOptions->SetEnableConnectionsLog( m_propStorage.GetEnableConnectionsLog() );
	m_pLogOptions->SetEnableBandwidthLog( m_propStorage.GetEnableBandwidthLog() );
	m_pLogOptions->SetEnableAccessLog( m_propStorage.GetEnableAccessLog() );
	m_pLogOptions->SetEnableADSLLog( m_propStorage.GetEnableADSLLog() );
	m_pLogOptions->SetEnableWirelessLog( m_propStorage.GetEnableWirelessLog() );
}

void CPropertyDlg::LoadPortForwardPageData()
{
	//PF
	m_pPFOptions->SetAutoPortForwardLowPort( m_propStorage.GetAutoPortForwardLowPort() );
	m_pPFOptions->SetEnableAllowPFPolicy( m_propStorage.GetEnableAllowPFPolicy() );
	m_pPFOptions->SetAllowPFPolicy( m_propStorage.GetAllowPFPolicy() );
	m_pPFOptions->SetEnableBlockPFPolicy( m_propStorage.GetEnableBlockPFPolicy() );
	m_pPFOptions->SetBlockPFPolicy( m_propStorage.GetBlockPFPolicy() );
}

void CPropertyDlg::Save(bool& bRestart)
{
	bRestart = false;

	for ( UIDATALIST::iterator iCur = m_uiData.begin();
				iCur!=m_uiData.end();iCur++ )
	{
		UIDATA& data = *iCur;
		PROPENTRY pp;
		
		m_propStorage.GetProperty(data.type, pp);
		
		pp.btWarningLevel = data.pLevel->GetWarningLevel();
		pp.btAlarmLevel = data.pLevel->GetAlarmLevel();
		
		pp.onWarning = data.pReaction->GetWarningStrat();
		pp.onAlarm = data.pReaction->GetAlarmStrat();
		pp.onWarningScript = data.pReaction->GetWarningScript();
		pp.onAlarmScript = data.pReaction->GetAlarmScript();
		pp.bEnableRepair = false;

		if ( data.pEnableLeaksProtection && data.pEnableLeaksProtection->GetValue() )
		{
			pp.bEnableRepair = true;
		}
		
		m_propStorage.SetProperty(data.type, pp);
	}

	//Run at startup
	m_propStorage.SetBootRun( m_pGeneral->GetBootRun() );

	//Check for updates
	m_propStorage.SetUpdCheck( m_pGeneral->GetUpdCheck() );


	//NAT Optimization
	m_propStorage.SetEnableNATOpt( m_pGeneral->GetEnableNATOpt() );

	//NAT Size Optimization
	m_propStorage.SetEnableNATSizeOpt( m_pGeneral->GetEnableNATSizeOpt() );

	//Peer To Peer
	m_propStorage.SetEnableP2PNetworkOpt( m_pGeneral->GetEnableP2PNetworkOpt() );

	//WWW
	m_propStorage.SetEnableWWWOpt( m_pGeneral->GetEnableWWWOpt() );

	//TCP
	m_propStorage.SetEnableTCPOpt( m_pGeneral->GetEnableTCPOpt() );

	//icmp
	m_propStorage.SetEnableICMPOpt( m_pGeneral->GetEnableICMPOpt() );

	//Advanced
	m_propStorage.SetEnableAdvancedOpt( m_pGeneral->GetEnableAdvancedOpt() );
	m_propStorage.SetAdvancedOptList( m_pGeneral->GetAdvancedOptList() );

	//Language
	if ( m_pGeneral->GetLanguage()!=m_propStorage.GetLanguage() )
	{
		m_propStorage.SetLanguage(  m_pGeneral->GetLanguage() );

		int nRes = wxMessageBox(_("You need to restart the application before\n the language change will take effect.\nRestart Now?"), _("Info"),
				wxICON_QUESTION  | wxYES_NO, this);

		if ( wxYES==nRes )
		{
			bRestart = true;

		}
	}

	//StartUP Script
	m_propStorage.SetEnableStartUpScript( m_pGeneral->GetEnableStartUpScript() );
	m_propStorage.SetStartUpScriptFileName( m_pGeneral->GetStartUpScriptFileName() );

	//Proc Kill
	m_propStorage.SetEnableProcKill(  m_pGeneral->GetEnableProcKill() );
	m_propStorage.SetProcKillList(  m_pGeneral->GetProcKillList() );

	//Mod Unload
	m_propStorage.SetEnableModUnload(  m_pGeneral->GetEnableModUnload() );
	m_propStorage.SetModUnloadList(  m_pGeneral->GetModUnloadList() );

	//SysLog 
	m_propStorage.SetSysLogFromRouterOnly( m_pSysLog->GetSysLogFromRouterOnly() );
	m_propStorage.SetSysLogActions( m_pSysLog->GetSysLogActions() );
	m_propStorage.SetLogBlockedMAC( m_pSysLog->GetLogBlockedMAC() );
	m_propStorage.SetEnableSyslogSave( m_pSysLog->GetEnableSyslogSave() );
	m_propStorage.SetSyslogSaveFileName( m_pSysLog->GetSyslogSaveFileName() );
	m_propStorage.SetSyslogSaveLimit( m_pSysLog->GetSyslogSaveLimit() );
	m_propStorage.SetSysLogUDPPort(  m_pSysLog->GetSysLogUDPPort() );
	m_propStorage.SetEnableSyslogAutoConfig( m_pSysLog->GetEnableSyslogAutoConfig() );
	m_propStorage.SetSyslogAutoConfigLevel( m_pSysLog->GetSyslogAutoConfigLevel() );

	

	//SMTP Server
	m_propStorage.SetSMTPServer( m_pNotify->GetSMTPServer() );

	//SMTP Server Port
	m_propStorage.SetSMTPServerPort( m_pNotify->GetSMTPServerPort() );

	//SMTP User
	m_propStorage.SetSMTPUser( m_pNotify->GetSMTPUser() );

	//SMTP Passw
	m_propStorage.SetSMTPPassw( m_pNotify->GetSMTPPassw() );

	//SMTP From
	m_propStorage.SetSMTPFrom( m_pNotify->GetSMTPFrom());

	//SMTP To
	m_propStorage.SetSMTPTo( m_pNotify->GetSMTPTo());


	//Send application Log
	m_propStorage.SetSendAppLog( m_pNotify->GetSendAppLog() );

	//Send syslog Log
	m_propStorage.SetSendSysLog( m_pNotify->GetSendSysLog() );

	//Send syslog Log Level
	m_propStorage.SetSyslogSendLevel( m_pNotify->GetSyslogSendLevel() );

	//Send interval
	m_propStorage.SetSendPeriod( m_pNotify->GetSendPeriod() );

	//Sched
	m_propStorage.SetSchedulerEnabled( m_pScheduler->GetSchedulerEnabled() );
	m_propStorage.SetScheduler( m_pScheduler->GetScheduler() );

	//Log
	m_propStorage.SetEnableAppLogSave( m_pLogOptions->GetEnableAppLogSave() );
	m_propStorage.SetAppLogSaveFileName( m_pLogOptions->GetAppLogSaveFileName() );
	m_propStorage.SetAppLogSaveLimit( m_pLogOptions->GetAppLogSaveLimit() );
	m_propStorage.SetAppLogStatusInterval( m_pLogOptions->GetAppLogStatusInterval() );
	m_propStorage.SetEnablePerfomanceLog( m_pLogOptions->GetEnablePerfomanceLog() );
	m_propStorage.SetEnableConnectionsLog( m_pLogOptions->GetEnableConnectionsLog() );
	m_propStorage.SetEnableBandwidthLog( m_pLogOptions->GetEnableBandwidthLog() );
	m_propStorage.SetEnableAccessLog( m_pLogOptions->GetEnableAccessLog() );
	m_propStorage.SetEnableADSLLog( m_pLogOptions->GetEnableADSLLog() );
	m_propStorage.SetEnableWirelessLog( m_pLogOptions->GetEnableWirelessLog() );

	//Port Forwarding
	m_propStorage.SetAutoPortForwardLowPort( m_pPFOptions->GetAutoPortForwardLowPort() );

	m_propStorage.SetEnableAllowPFPolicy( m_pPFOptions->GetEnableAllowPFPolicy() );
	m_propStorage.SetAllowPFPolicy( m_pPFOptions->GetAllowPFPolicy() );
	m_propStorage.SetEnableBlockPFPolicy( m_pPFOptions->GetEnableBlockPFPolicy() );
	m_propStorage.SetBlockPFPolicy( m_pPFOptions->GetBlockPFPolicy() );
}

/////////////////////////////////////////////////////////////////////////
//Events
void CPropertyDlg::OnHelp(wxHelpEvent& event)
{
	wxGetApp().RunHelp( wxT("#options") );
}

void CPropertyDlg::OnHelpButton(wxCommandEvent& event)
{
	wxGetApp().RunHelp( wxT("#options") );
}